package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//自媒体文章管理-查询所有频道
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Autowired
    private WmChannelService wmChannelService;

    /**
     * TODO：所有频道查询
     * @return
     */
    @GetMapping("/channels")
    public ResponseResult findAll(){
        return wmChannelService.findAll();
    }

    /**
     * 频道-模糊分页查询
     * @return
     */
    @PostMapping("/list")
    public ResponseResult likeSearch(@RequestBody ChannelDto dto){
        return wmChannelService.likeSearch(dto);
    }

    /**
     * 新增频道
     * @param wmChannel
     * @return
     */
    @PostMapping("/save")
    public ResponseResult addChannel(@RequestBody WmChannel wmChannel) {
        return  wmChannelService.addChannel(wmChannel);
    }


    /**
     * 修改频道
     * @param wmChannel
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel) {
        return  wmChannelService.updateChannel(wmChannel);
    }

    /**
     * 删除频道
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable Integer id) {
        return  wmChannelService.deleteChannel(id);
    }
}